package cn.zzp.homework.sync;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * @ClassName Producer
 * @Description
 * @Author 祝志鹏
 * @Date 2022/8/17 16:31
 */
public class Producer {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer("sync_product_group");

        producer.setNamesrvAddr("localhost:9876");

        producer.start();

        Message message = new Message("sync", "hello", "同步测试消息发送".getBytes(StandardCharsets.UTF_8));

        SendResult send = producer.send(message);

        System.out.println(send);

        producer.shutdown();
    }

}
